import QtQuick 2.15
import QtQuick.Controls 2.15

Rectangle {
    id: section
    width: parent.width
    height: childrenRect.height
    radius: 8
    property string title
    color: "#f0f0f0"
    Rectangle {
        id: rect
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.top: parent.top
        height: 50
        radius: 8
        color: "#f0f0f0"

        Text {
            anchors.verticalCenter: parent.verticalCenter
            anchors.left: parent.left
            anchors.leftMargin: 15
            text: section.title
            font.pixelSize: 16
            font.bold: true
            color: "#333"
        }
    }

    Column {
        spacing: 10
        anchors.top: rect.bottom
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.margins: 10

        Repeater {
            model: [
                { label: "Tun 模式", switchId: "tunModeSwitch" },
                { label: "服务模式", switchId: "serviceModeSwitch" },
                { label: "系统代理", switchId: "systemProxySwitch", checked: true },
                { label: "开机自启", switchId: "autoStartSwitch" },
                { label: "静默启动", switchId: "silentStartSwitch" }
            ]

            delegate: Row {
                spacing: 10
                height: 30
                width: parent.width

                Label {
                    text: modelData.label
                    font.pixelSize: 14
                    color: "#333"
                }


                Switch {
                    anchors.right: parent.right
                    checked: modelData.checked !== undefined ? modelData.checked : false
                }
            }
        }
    }
}
